package com.bright.hxj.cwduijie.service.impl;

import com.bright.hxj.cwduijie.enums.DataApi;
import com.bright.hxj.cwduijie.pojo.bo.ApiDataCollection;
import com.bright.hxj.cwduijie.pojo.po.OrgMapLocation;
import com.bright.hxj.cwduijie.pojo.query.DuijieQuery;
import com.bright.hxj.cwduijie.repository.OrgMapLocationRepository;
import com.bright.hxj.cwduijie.service.AbstractPerThousandApiService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.function.Function;

/**
 * @Author hxj
 * @Date 2024/11/21 15:45
 * @Description
 */
@Component
@RequiredArgsConstructor
public class ApiOrgMapLocationServiceImpl extends AbstractPerThousandApiService<OrgMapLocation> {

    private final OrgMapLocationRepository repo;

    @Override
    protected void getData(ApiDataCollection apiDataCollection, DuijieQuery duijieQuery) {
        apiDataCollection.setOrgMapLocations(getNeedDuijieData(duijieQuery));
    }

    @Override
    public JpaSpecificationExecutor getJpaSpecificationExecutor() {
        return repo;
    }

    @Override
    public DataApi getDataApi() {
        return DataApi.ORG_MAP_LOCATION;
    }

    @Override
    public Function<OrgMapLocation, Integer> getIdFunc() {
        return OrgMapLocation::getID;
    }

    @Override
    public Function<OrgMapLocation, String> getDataKeyFunc() {
        return OrgMapLocation::getDATA_KEY;
    }

    @Override
    public Function<ApiDataCollection, List<OrgMapLocation>> getDataFunc() {
        return ApiDataCollection::getOrgMapLocations;
    }

    @Override
    public DataApi getDeleteDataApi() {
        return DataApi.DELETE_ORG_MAP_LOCATION;
    }
}
